package exp.parser;

import grammar.parser.FuncFParams;
import word.parser.WordElement;

public class Exp extends ExpParser {
    private final AddExp addExp;

    public Exp(AddExp exp) {
        super(exp.isComputable(), exp.isConst());
        this.addExp = exp;
    }

    public static Exp buildExp() {
        return new Exp(AddExp.parserAddExp());
    }

    public static boolean isExpPrefix(WordElement element) {
        WordElement.WordType type = element.getType();
        return type == WordElement.WordType.LPARENT ||
                type == WordElement.WordType.INTCON ||
                type == WordElement.WordType.IDENFR ||
                type == WordElement.WordType.PLUS ||
                type == WordElement.WordType.MINU;
    }

    @Override
    public FuncFParams.FuncFParam checkDimension() {
        return addExp.checkDimension();
    }

    @Override
    public LVal toLVal() {
        return addExp.toLVal();
    }

    @Override
    public Integer compute() {
        return addExp.compute();
    }
}
